﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserConTrols_Quang_Cao : System.Web.UI.UserControl
{
    DataProvider duLieu = new DataProvider();
    ListBox listBox = new ListBox();

    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (!IsPostBack)
        {
            DataList1.DataSource = duLieu.Load_Du_Lieu_New("select * from quangcao", listBox);
            DataList1.DataBind();
        }
    }
    public string resize_ha(string Link_Anh, string Link_Web, string Tieu_De)
    {
        System.Drawing.Image myImage = System.Drawing.Image.FromFile(Server.MapPath("hinh_quang_cao\\") + Link_Anh);
        int chieudai = myImage.Width;
        int chieucao = myImage.Height;
        if (myImage.Width > 122)
        {
            chieudai = 122;
        }
        if (myImage.Height > 160)
        {
            chieucao = 160;
        }
        return "<a title='" + Tieu_De + "' href='" + Link_Web + "' target='_blank'><img width='" + chieudai + "' height='" + chieucao + "' title='" + Tieu_De + "' src='" + "hinh_quang_cao/" + Link_Anh + "' alt='" + Tieu_De + "' style='border-width:0px;'/></a>";
    }
}